home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Development / MosaicSRC / libwww2 / HTGroup.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-13  |  5.3 KB  |  185 lines

  1. /*                                    GROUP FILE ROUTINES
  2.                                              
  3.  */
  4.  
  5. #ifndef HTGROUP_H
  6. #define HTGROUP_H
  7.  
  8. #include "HTUtils.h"
  9. #include "HTList.h"
  10.  
  11. #ifdef SHORT_NAMES
  12. #define HTAApGrD        HTAA_parseGroupDef
  13. #define HTAArGrR        HTAA_resolveGroupReferences
  14. #define HTAApGrD        HTAA_printGroupDef
  15. #define HTAAGD_d        GroupDef_delete
  16. #define HTAAuIIG        HTAA_userAndInetInGroup
  17. #endif /* SHORT_NAMES */
  18.  
  19. typedef HTList GroupDefList;
  20. typedef HTList ItemList;
  21.  
  22. typedef struct {
  23.     char *      group_name;
  24.     ItemList *  item_list;
  25. } GroupDef;
  26.  
  27.  
  28. /*
  29. ** Access Authorization failure reasons
  30. */
  31. typedef enum {
  32.     HTAA_OK,            /* 200 OK                               */
  33.     HTAA_NO_AUTH,       /* 401 Unauthorized, not authenticated  */
  34.     HTAA_NOT_MEMBER,    /* 401 Unauthorized, not authorized     */
  35.     HTAA_IP_MASK,       /* 403 Forbidden by IP mask             */
  36.     HTAA_BY_RULE,       /* 403 Forbidden by rule                */
  37.     HTAA_NO_ACL,        /* 403 Forbidden, ACL non-existent      */
  38.     HTAA_NO_ENTRY,      /* 403 Forbidden, no ACL entry          */
  39.     HTAA_SETUP_ERROR,   /* 403 Forbidden, server setup error    */
  40.     HTAA_NOT_FOUND      /* 404 Not found, or read protected     */
  41. } HTAAFailReasonType;
  42.  
  43. /*
  44.  
  45. Group definition grammar
  46.  
  47.   string
  48.                          "sequence of alphanumeric characters"
  49.                          
  50.   user_name
  51.                          string
  52.                          
  53.   group_name
  54.                          string
  55.                          
  56.   group_ref
  57.                          group_name
  58.                          
  59.   user_def
  60.                          user_name | group_ref
  61.                          
  62.   user_def_list
  63.                            user_def { ',' user_def }
  64.                          
  65.   user_part
  66.                          user_def | '(' user_def_list ')'
  67.                          
  68.   templ
  69.                          
  70.                          "sequence of alphanumeric characters and '*'s"
  71.                          
  72.   ip_number_mask
  73.                          templ '.' templ '.' templ '.' templ
  74.                          
  75.   domain_name_mask
  76.                          templ { '.' templ }
  77.                          
  78.   address
  79.                          
  80.                          ip_number_mask | domain_name_mask
  81.                          
  82.   address_def
  83.                          
  84.                          address
  85.                          
  86.   address_def_list
  87.                          address_def { ',' address_def }
  88.                          
  89.   address_part
  90.                          address_def | '(' address_def_list ')'
  91.                          
  92.   item
  93.                          [user_part] ['@' address_part]
  94.                          
  95.   item_list
  96.                          item { ',' item }
  97.                          
  98.   group_def
  99.                          item_list
  100.                          
  101.   group_decl
  102.                          group_name ':' group_def
  103.                          
  104.   PARSE GROUP DEFINITION
  105.   
  106.  */
  107.  
  108. PUBLIC GroupDef *HTAA_parseGroupDef PARAMS((FILE * fp));
  109. /*
  110.  
  111. Fill in Pointers to referenced Group Definitions in a Group Definition
  112.  
  113.    References to groups (by their name) are resolved from group_def_list and pointers to
  114.    those structures are added to group_def.
  115.    
  116.  */
  117.  
  118. PUBLIC void HTAA_resolveGroupReferences PARAMS((GroupDef *     group_def,
  119.                                                 GroupDefList * group_def_list));
  120. /*
  121.  
  122. Read Group File (and do caching)
  123.  
  124.    If group file is already in cache returns a pointer to previously read group definition
  125.    list.
  126.    
  127.  */
  128.  
  129. PUBLIC GroupDefList *HTAA_readGroupFile PARAMS((CONST char * filename));
  130. /*
  131.  
  132. Delete Group Definition
  133.  
  134.    Groups in cache should never be freed by this function. This should only be used to
  135.    free group definitions read by HTAA_parseGroupDef.
  136.    
  137.  */
  138.  
  139. PUBLIC void GroupDef_delete PARAMS((GroupDef * group_def));
  140. /*
  141.  
  142. Print Out Group Definition (for trace purposes)
  143.  
  144.  */
  145.  
  146. PUBLIC void HTAA_printGroupDef PARAMS((GroupDef * group_def));
  147. /*
  148.  
  149. Does a User Belong to a Given Set of Groups
  150.  
  151.    This function checks both the username and the internet address.
  152.    
  153.  */
  154.  
  155. /* PUBLIC                                       HTAA_userAndInetInGroup()
  156. **              CHECK IF USER BELONGS TO TO A GIVEN GROUP
  157. **              AND THAT THE CONNECTION COMES FROM AN
  158. **              ADDRESS THAT IS ALLOWED BY THAT GROUP
  159. ** ON ENTRY:
  160. **      group           the group definition structure.
  161. **      username        connecting user.
  162. **      ip_number       browser host IP number, optional.
  163. **      ip_name         browser host IP name, optional.
  164. **                      However, one of ip_number or ip_name
  165. **                      must be given.
  166. ** ON EXIT:
  167. **      returns         HTAA_IP_MASK, if IP address mask was
  168. **                      reason for failing.
  169. **                      HTAA_NOT_MEMBER, if user does not belong
  170. **                      to the group.
  171. **                      HTAA_OK if both IP address and user are ok.
  172. */
  173. PUBLIC HTAAFailReasonType HTAA_userAndInetInGroup PARAMS((GroupDef * group,
  174.                                                           char *     username,
  175.                                                           char *     ip_number,
  176.                                                           char *     ip_name));
  177. /*
  178.  
  179.  */
  180.  
  181. #endif /* not HTGROUP_H */
  182. /*
  183.  
  184.    End of file HTGroup.h.  */
  185.